<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      div {
        border: 3px solid;
        padding: 10px;
      }
    </style>
  </head>
  <body>
    <div id="box1">
      box1
      <div id="box2">
        box2
        <div id="box3">
          box3
          <div id="box4">box4</div>
        </div>
      </div>
    </div>
    <script>
      const box1 = document.getElementById("box1");
      const box2 = document.getElementById("box2");
      const box3 = document.getElementById("box3");
      const box4 = document.getElementById("box4");

      window.addEventListener("click", () => console.log("window"), {
        capture: true,
      });

      document.addEventListener("click", () => console.log("document"), {
        capture: true,
      });

      document.documentElement.addEventListener(
        "click",
        () => console.log("html"),
        {
          capture: true,
        }
      );

      document.documentElement.addEventListener(
        "click",
        () => console.log("body"),
        {
          capture: true,
        }
      );

      box1.addEventListener("click", () => console.log("capture", 1), {
        capture: true,
      });
      box2.addEventListener("click", () => console.log("capture", 2), {
        capture: true,
      });
      box3.addEventListener("click", () => console.log("capture", 3), {
        capture: true,
      });
      box4.addEventListener("click", () => console.log("capture", 4), {
        capture: true,
      });

      box4.addEventListener("click", () => console.log("", 4));
      box3.addEventListener("click", () => console.log("", 3));
      box2.addEventListener("click", () => console.log("", 2));
      box1.addEventListener("click", () => console.log("", 1));
    </script>
  </body>
</html>
